package com.quanyan.stadium.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: zyq
 * Date: 2016/11/18 0018
 * Time: 15:54
 */

public class DateUtil {
    private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm";

    @SuppressWarnings("rawtypes")
    private static ThreadLocal threadLocal = new ThreadLocal() {
        protected synchronized Object initialValue() {
            return new SimpleDateFormat(DATE_FORMAT);
        }
    };

    public static DateFormat getDateFormat() {
        return (DateFormat) threadLocal.get();
    }

    public static Date parse(String textDate) throws ParseException {
        return getDateFormat().parse(textDate);
    }

    public static String deParse(Date date){
        return getDateFormat().format(date);
    }

    public static String getSpecialDateStr(){
        return "[" + getDateFormat().format(new Date()) + "]";
    }

}
